﻿using System;
using System.Data;
using System.Collections.Generic;
using KF.DHLModel;
namespace KF.DHL.BLL
{
	/// <summary>
	/// AdditionalCharge
	/// </summary>
	public partial class AdditionalChargeBLL
	{
        private readonly KF.DHL.DAL.AdditionalChargeDAL dal = new KF.DHL.DAL.AdditionalChargeDAL();
        public AdditionalChargeBLL()
		{}
		#region  Method

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(KF.DHLModel.AdditionalCharge model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(KF.DHLModel.AdditionalCharge model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public KF.DHLModel.AdditionalCharge GetModel(int ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<KF.DHLModel.AdditionalCharge> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<KF.DHLModel.AdditionalCharge> DataTableToList(DataTable dt)
		{
			List<KF.DHLModel.AdditionalCharge> modelList = new List<KF.DHLModel.AdditionalCharge>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				KF.DHLModel.AdditionalCharge model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new KF.DHLModel.AdditionalCharge();
					if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
					{
						model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
					}
					if(dt.Rows[n]["CustomerCode"]!=null && dt.Rows[n]["CustomerCode"].ToString()!="")
					{
					model.CustomerCode=dt.Rows[n]["CustomerCode"].ToString();
					}
					if(dt.Rows[n]["OrderNumber"]!=null && dt.Rows[n]["OrderNumber"].ToString()!="")
					{
					model.OrderNumber=dt.Rows[n]["OrderNumber"].ToString();
					}
					if(dt.Rows[n]["RefOrderNumber"]!=null && dt.Rows[n]["RefOrderNumber"].ToString()!="")
					{
					model.RefOrderNumber=dt.Rows[n]["RefOrderNumber"].ToString();
					}
					if(dt.Rows[n]["Amount"]!=null && dt.Rows[n]["Amount"].ToString()!="")
					{
					//model.Amount=dt.Rows[n]["Amount"].ToString();
					}
					if(dt.Rows[n]["Notes"]!=null && dt.Rows[n]["Notes"].ToString()!="")
					{
					model.Notes=dt.Rows[n]["Notes"].ToString();
					}
					if(dt.Rows[n]["AddTime"]!=null && dt.Rows[n]["AddTime"].ToString()!="")
					{
						model.AddTime=DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
					}
					if(dt.Rows[n]["Status"]!=null && dt.Rows[n]["Status"].ToString()!="")
					{
						model.Status=int.Parse(dt.Rows[n]["Status"].ToString());
					}
					if(dt.Rows[n]["BillWho"]!=null && dt.Rows[n]["BillWho"].ToString()!="")
					{
					model.BillWho=dt.Rows[n]["BillWho"].ToString();
					}
					if(dt.Rows[n]["BillDate"]!=null && dt.Rows[n]["BillDate"].ToString()!="")
					{
						model.BillDate=DateTime.Parse(dt.Rows[n]["BillDate"].ToString());
					}
					if(dt.Rows[n]["BillAmount"]!=null && dt.Rows[n]["BillAmount"].ToString()!="")
					{
						model.BillAmount=DateTime.Parse(dt.Rows[n]["BillAmount"].ToString());
					}
					if(dt.Rows[n]["AddWho"]!=null && dt.Rows[n]["AddWho"].ToString()!="")
					{
					model.AddWho=dt.Rows[n]["AddWho"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

